using Vin.Extension.Framework.Quartz.Entities;

namespace Vin.Extension.Framework.Quartz.Models;

public class JobInfo
{
    /// <summary>
    /// 任务名称
    /// </summary>
    public string? Name { get; set; }

    /// <summary>
    /// 任务分组名称
    /// </summary>
    public string? GroupName { get; set; }

    /// <summary>
    /// 任务执行类型
    /// </summary>
    public JobExecuteType? ExecuteType { get; set; } = JobExecuteType.Generics;

    /// <summary>
    /// 程序集路径
    /// </summary>
    public string? AssemblyPath { get; set; }

    /// <summary>
    /// 执行的程序集名称
    /// </summary>
    public string? AssemblyName { get; set; }

    /// <summary>
    /// 执行的任务类名
    /// </summary>
    public string? ClassName { get; set; }

    /// <summary>
    /// 任务参数
    /// </summary>
    public Dictionary<string, string> Parameters { get; set; } = new();

    /// <summary>
    /// 是否立即启动一次
    /// </summary>
    public bool? FirstExecute { get; set; }

    /// <summary>
    /// 开始时间
    /// </summary>
    public DateTime? StartTime { get; set; }

    /// <summary>
    /// 结束时间
    /// </summary>
    public DateTime? EndTime { get; set; }

    /// <summary>
    /// 任务触发器类型
    /// </summary>
    public JobTriggerType? TriggerType { get; set; } = JobTriggerType.Simple;

    /// <summary>
    /// 循环类型
    /// </summary>
    public JobLoopType? LoopType { get; set; } = JobLoopType.Once;

    /// <summary>
    /// 循环次数
    /// </summary>
    public int? LoopCount { get; set; }

    /// <summary>
    /// 间隔类型
    /// </summary>
    public JobIntervalType? IntervalType { get; set; } = JobIntervalType.Second;

    /// <summary>
    /// 间隔值
    /// </summary>
    public int? IntervalValue { get; set; }

    /// <summary>
    /// Cron表达式
    /// </summary>
    public string? Cron { get; set; }

    public JobInfo(string name, string groupName)
    {
        this.Name = name;
        this.GroupName = groupName;
    }

    public JobInfo(string name, string groupName, Dictionary<string, string>? parameters = null)
    {
        this.Name = name;
        this.GroupName = groupName;
        this.Parameters = parameters ?? new();
    }
}